import router from "./router";
import store from "@/store"; // 验权
import NProgress from "nprogress";
const WHITE_LIST = ["/login", "/findpassword", "/privacyPolicy"];
router.beforeEach((to, from, next) => {
  NProgress.start();
  loading.open();
  if (store.getters.isAuthed) {
    if (to.path === "/login") {
      next({
        path: "/",
      });
    } else {
      next();
    }
  } else {
    if (WHITE_LIST.indexOf(to.path) !== -1) {
      next();
    } else {
      next("/login");
    }
  }
});

router.afterEach(() => {});
